/**
 * @计算数组的和
 *
 * @author	 wangshikun <wangshikun2010@gmail.com>
 * @copyright	(c) 2012 wangshikun <wangshikun2010@gmail.com>
 * @license	http://www.opensource.org/licenses/mit-license.php The MIT License
 * @package	default
 * @subpackage	default
 */

#include <stdio.h>
#include <cs50.h>

//声明函数
int sum (int values[],int number);

int main(int argc, char *argv[]) {
	int number, num;

	do {
		printf("数量：");
		scanf("%d", &number);
	} while (number <=0 );

	int scores[number];

	//将输入的n个数存放在score数组里
	for (int i=0; i<number; i++) {
		printf("请输入%d个数：", i+1);
		scanf("%d", &scores[i]);
	}

	printf("数组的和是：%d\n", sum(scores, number));
	
	return 0;
}

int sum (int values[],int number) {
	int s = 0;

	for (int i=0; i<number; i++) {
		s += values[i];
	}

	return s;
}
